//
//  MonthlyReportViewController.m
//  Ai
//
//  Created by 杜超男 on 2019/3/13.
//  Copyright © 2019年 杜超男. All rights reserved.
//

#import "MonthlyReportViewController.h"
#import "Masonry.h"
#import "MonthlyReportDetailsTableViewCell.h"
#import "DetailsBtnViewController.h"
@interface MonthlyReportViewController ()<UITableViewDelegate , UITableViewDataSource>
@property (nonatomic , strong)UITableView *tableView;
@end

@implementation MonthlyReportViewController
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = YES;
    self.tabBarController.tabBar.hidden = YES;
}
- (IBAction)BackBtn:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)SearchBtn:(id)sender {
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self search];
    [self backgroundColor];
    [self.view addSubview:self.tableView];
    [_tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop).inset(125);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.bottom.mas_equalTo(0);
    }];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MonthlyReportDetails) name:@"MonthlyReportDetails" object:nil];
    // Do any additional setup after loading the view from its nib.
}
- (void)MonthlyReportDetails{//详情按钮的点击方法
    DetailsBtnViewController *detail = [[DetailsBtnViewController alloc] init];
    
    [self.navigationController pushViewController:detail animated:YES];
    
}
-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(UITableView *)tableView{
    _tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.showsVerticalScrollIndicator = NO;
    _tableView.rowHeight = 440;
    [_tableView registerNib:[UINib nibWithNibName:@"MonthlyReportDetailsTableViewCell" bundle:nil] forCellReuseIdentifier:@"MonthlyReportDetailsTableViewCell"];
    return _tableView;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 10;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MonthlyReportDetailsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MonthlyReportDetailsTableViewCell"];
    if (!cell) {
        cell = [[MonthlyReportDetailsTableViewCell alloc]initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"MonthlyReportDetailsTableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.01;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0.01)];
    headerView.backgroundColor = [UIColor clearColor];
    return headerView;
}
- (void)backgroundColor{
    UIView *BackgroundColorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    BackgroundColorView.backgroundColor = [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1];
    [self.view addSubview:BackgroundColorView];
    [BackgroundColorView sendSubviewToBack:self.view];
    BackgroundColorView.translatesAutoresizingMaskIntoConstraints = NO;
    [BackgroundColorView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop).inset(115);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
}
- (void)search{
    UISearchBar *search = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 310, 30)];
    search.placeholder = @"搜索活动关键词，园所名称等";
    search.searchBarStyle = UISearchBarStyleMinimal;
    [self.view addSubview:search];
    search.translatesAutoresizingMaskIntoConstraints = NO;
    [search mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop).inset(23);
        make.left.mas_equalTo(41);
        make.right.mas_equalTo(-59);
        
    }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
